<template>
	<view class="page tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
		<view class="top-bg"></view>
		<dawnBar title="医院简介"></dawnBar>
		<view class="page-container" style="padding-bottom: 140rpx;">
			<!-- banner -->
			<!-- <tn-swiper :list="banner" name="picUrl" :height="300" :effect3d="false" mode="rect"
				:radius="15"></tn-swiper> -->
			
			<!-- 医院信息 -->
			<view class="hosp-info" style="margin-top: 0;">
				<view class="list-item" style="padding: 10px;">
					<!-- <view class="list-head tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-between">
						<view class="justify-content-item ">
							<tn-tag backgroundColor="tn-main-gradient-dawn" fontColor="#FFFFFF" shape="circleRight"
								width="auto" fontSize="dawn-text-lg">
								{{ appConfig.appTitle || ''}}
							</tn-tag>
						</view>
					</view> -->
					<view class="list-content tn-flex tn-flex-nowrap tn-flex-col-center tn-flex-row-between">
						<view class="tn-flex tn-flex-direction-column">
							<view class="tn-flex tn-flex-nowrap  tn-flex-col-center tn-flex-row-left">
								<view @click="navDteail(item)" v-if="appConfig.logoUrl">
									<!-- <image mode="aspectFill" class="hosp-image" :src="appConfig.logoUrl"/> -->
									<tn-avatar :src="appConfig.logoUrl" size="120rpx"></tn-avatar>
								</view>
								<view class="tn-padding-left-xs">
									<view>
										<!-- <tn-tag backgroundColor="tn-main-gradient-dawn" fontColor="#FFFFFF" shape="circleRight"
											width="auto" fontSize="dawn-text-lg">
											{{ appConfig.appTitle || ''}}
										</tn-tag> -->
										<text
											class="dawn-text-md tn-text-bold tn-color-dawn">{{ appConfig.appTitle || ''}}</text>
									</view>
									<view class="tn-margin-top-ss">
										<tn-tag
											class="dawn-tag-sm dawn-tag-sm__1">{{appConfig.companyRespVO.level || '' }}</tn-tag>
										<text class="tn-color-gray tn-padding-left-xs tn-padding-right-xs">|</text>
										<tn-tag
											class="dawn-tag-sm dawn-tag-sm__2">{{appConfig.companyRespVO.nature || '' }}</tn-tag>
										<text class="tn-color-gray tn-padding-left-xs tn-padding-right-xs">|</text>
										<tn-tag
											class="dawn-tag-sm dawn-tag-sm__3">{{appConfig.companyRespVO.business || '' }}</tn-tag>
									</view>
									<view class="tn-margin-top-xs">
										<view @click="callPhoneNumber(appConfig.companyRespVO.phone)">
											<!-- <text class="tn-color-black">电话：</text> -->
											<text 
												class="tn-icon-tel-circle-fill tn-margin-right-xs tn-color-dawn"></text>
											<text
												class="tn-text-md">{{ appConfig.companyRespVO.phone  || '' }}</text>
											
										</view>
									</view>
								</view>
							</view>
			
							<view class="tn-margin-top-xs" @click="navNoAuth('/hosp/company/map')">
								<view>
									<text class="tn-icon-map-fill tn-margin-right-xs tn-color-dawn"></text>
									<text>{{appConfig.companyRespVO.address || '' }}</text>
								</view>
							</view>
			
						</view>
						<!-- <view @click="navDteail(appConfig)"
							class="tn-flex tn-flex-nowrap tn-flex-col-center tn-flex-row-right">
							<view class="tn-text-right">
								<text class="tn-icon-right tn-color-gray"></text>
							</view>
						</view> -->
					</view>
				</view>
			</view>
			
			<view class="tn-bg-white dawn-shadow dawn-radius">
				<view class='newsDetail'>
					<!-- <view class='title'>{{ company.name}}</view>
					<view class='item tn-flex tn-flex-row-left tn-flex-col-center'>
						<view v-if="company.author" class='tn-margin-right-xs'>{{ company.author }}</view>
						<view class='tn-margin-right-xs'><text
								class='tn-icon-time-fill tn-padding-right-xs'></text>{{ formatDate(company.createTime) }}
						</view>
						<view class='tn-margin-right-xs'><text
								class='tn-icon-footprint tn-padding-right-xs'></text>{{ company.browseCount }}
						</view>
					</view> -->
					<view class='conters'>
						<jyf-parser :html="company.content" ref="article" :tag-style="tagStyle" />
					</view>
					
					<view v-show="company.content" class="tn-flex tn-flex-row-center tn-flex-col-center">
						<view class="tn-width-full">
							<!-- #ifdef H5 -->
							<button style="width: 70%;" class="bnt " hover-class='none' @click="listenerActionSheet"
								v-if="this.$wechat.isWeixin()">
								和好友一起分享
							</button>
							<!-- #endif -->
							<!-- #ifdef MP -->
							<button style="width: 70%;" class="bnt " open-type="share" hover-class='none'>和好友一起分享</button>
							<!-- #endif -->
						</view>
					</view>
					
				</view>
				<shareInfo @setShareInfoStatus="setShareInfoStatus" :shareInfoStatus="shareInfoStatus" />
			</view>
		</view>
		
		<!-- 悬浮按钮-->
		<NavBtn></NavBtn>
	</view>
</template>

<script>
	import page_mixin from '@/mixins/page_mixin.js'
	import NavBtn from '@/hosp/components/nav-fixed-button.vue'
	import shareInfo from '@/hosp/components/shareInfo';
	import parser from "@/hosp/components/jyf-parser/jyf-parser";
	import dayjs from "@/plugin/dayjs/dayjs.min.js";
	import * as Util from '@/utils/util.js';
	import {
		mapGetters
	} from "vuex";
	const app = getApp();

	export default {
		name: 'newsDetail',
		components: {
			shareInfo,
			NavBtn,
			"jyf-parser": parser
		},
		mixins: [page_mixin],
		computed: mapGetters(['appConfig','uid', 'isLogin', 'userInfo']),
		data() {
			return {
				id: 0,
				company: [],
				store_info: {},
				content: '',
				tagStyle: {
					img: 'width:100%;'
				},
				banner: [],
				productId: 0,
				shareInfoStatus: false,
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			this.company = this.appConfig.companyRespVO;
			if (options.hasOwnProperty('id')) {
				this.id = options.id;
			} else {
				// #ifndef H5
				// uni.navigateBack({
				// 	delta: 1
				// });
				// #endif
				// #ifdef H5
				// history.back();
				// #endif
			}
		},
		onShow: function() {
			// this.getArticleOne();
		},
		/**
		 * 用户点击右上角分享
		 */
		// #ifdef MP
		onShareAppMessage: function() {
			return {
				title: this.company.title,
				imageUrl: this.company.picUrl ? this.company.picUrl : "",
				desc: this.company.introduction,
				path: '/hosp/news/detail?id=' + this.id
			};
		},
		// #endif
		methods: {
			getArticleOne: function() {
				ArticleApi.getArticle(this.id).then(res => {
					// uni.setNavigationBarTitle({
					// 	title: res.data.title.substring(0, 7) + "..."
					// });
					this.$set(this, 'company', res.data);
					this.$set(this, 'productId', res.data.productId);

					this.content = res.data.content;
					// #ifdef H5
					if (this.$wechat.isWeixin()) {
						this.setShareInfo();
					}
					// #endif
				});
				// 增加文章浏览量
				ArticleApi.addArticleBrowseCount(this.id)
			},
			goodInfo(id) {
				ProductSpuApi.getSpuDetail(id).then(res => {
					this.$set(this, 'store_info', res.data);
				})
			},
			listenerActionSheet() {
				this.shareInfoStatus = true
			},
			setShareInfoStatus() {
				this.shareInfoStatus = false
			},
			setShareInfo: function() {
				let href = location.href;
				let configAppMessage = {
					title: this.company.title,
					desc: this.company.introduction,
					link: href,
					imgUrl: this.company.picUrl
				};
				this.$wechat.wechatEvevt([
					"updateAppMessageShareData",
					"updateTimelineShareData"
				], configAppMessage);
			},

			fen2yuan(price) {
				return Util.fen2yuan(price)
			},
			formatDate: function(date) {
				return dayjs(date).format("YYYY-MM-DD");
			}
		}
	}
</script>

<style lang="scss" scoped>
	.newsDetail {
		padding: 20rpx 0;
	}

	.newsDetail .title {
		padding: 0 30rpx;
		font-size: 34rpx;
		color: #282828;
		font-weight: bold;
		line-height: 1.5;
	}
	
	.newsDetail .item {
		padding: 20rpx 30rpx;
		// font-size: 34rpx;
		color: #8A8B8C;
		// font-weight: bold;
		line-height: 1.5;
	}

	.newsDetail .conters {
		padding: 30rpx;
		font-size: 30rpx;
		color: #282828;
		line-height: 1.7;
	}

	.newsDetail .bnt {
		color: #fff;
		font-size: 30rpx;
		width: 690rpx;
		height: 90rpx;
		border-radius: 45rpx;
		margin: 48rpx auto;
		text-align: center;
		line-height: 90rpx;
	}
</style>